using System;
using System.Linq.Expressions;
using Phoenix.Frames;
using Phoenix.Framework;
using Phoenix.Utilities;

namespace Phoenix.ActionResults
{
    public class RedirectActionResult<TController> : RedirectActionResult
    {
        public RedirectActionResult(ControllerActionContext context, Expression<Func<TController, ActionResult>> action)
            : base(() =>
                   {
                       var controllerActions = new InvokeActionBuilder(context);
                       var controllerType = typeof (TController);
                       var assemblyName = controllerType.Assembly.GetAssemblyName();
                       return controllerActions.InvokeExpression(controllerType.Name, controllerActions.GetExpressionFrom(action), assemblyName);
                   }, context)
        {
        }
    }
}